﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace GA.Server.ApiInfo
{
    [Serializable]
    public class ApiAchievement
    {
        public int CharacterId { get; private set; }
        public string Class { get; private set; }
        public DateTime EventTime { get; private set; }
        public string Message { get; private set; }
        public int PlayerId { get; private set; }
        public int Points { get; private set; }

        public ApiAchievement()
        {
        }

        public ApiAchievement(XmlReader reader)
        {
            while (!reader.EOF)
            {
                reader.Read();
                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case "a:character_id": CharacterId = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:class": Class = ApiXmlNode.GetValue(reader); break;
                        case "a:event_datetime": EventTime = DateTime.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:message": Message = ApiXmlNode.GetValue(reader); break;
                        case "a:player_id": PlayerId = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:points_earned": Points = int.Parse(ApiXmlNode.GetValue(reader)); break;
                    }
                }
            }
        }
    }
}
